package leetcode.offer_two_special.integer;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;

/**
 * @author mazouri
 * @create 2021-09-04 22:08
 */
public class _04_singleNumber {
    public int singleNumber(int[] nums) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            map.put(num, map.getOrDefault(num, 0)+1);
        }

        int res = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            if (entry.getValue() == 1) {
                res = entry.getKey();
                break;
            }
        }
        return res;
    }
}
